package com.apes.framework.plugin.condition.repository;

import com.apes.framework.jpa.repository.CustomRepository;
import com.apes.framework.plugin.condition.model.StrategyAuth;
import org.springframework.data.jpa.repository.Query;

import java.util.List;
import java.util.Map;

public interface StrategyAuthRepository extends CustomRepository<StrategyAuth, String> {
    @Query(value="SELECT A.ID,A.CONDITION_ID,A.AUT_CREATE,A.AUT_APPROVE,A.AUT_STOP,A.AUT_QRY_EXEC  FROM aut_condition A LEFT JOIN EXE_CONDITION B ON A.CONDITION_ID=B.ID WHERE  B.Id in (select id from EXE_CONDITION ) AND  A.ROLE_ID=:roleId AND B.VALID=1",nativeQuery = true)
    List<Map> findbyRoleId(String roleId);

    @Query(value="SELECT ID E_ID,NAME E_NAME,CONDITION_TYPE type,(0) AUT_CREATE,(0) AUT_APPROVE,(0) AUT_STOP,(0) AUT_QRY_EXEC FROM EXE_CONDITION WHERE VALID=1 ORDER BY ID DESC",nativeQuery = true)
    List<Map> findAllEXECondition();
}
